{extend name="../../base/view/common/base" /}
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">工作周报汇报</h3>
	<table class="layui-table layui-table-form">
		<tr>
			{if ($id == 0) OR ($detail.send_time == 0) }
			<td class="layui-td-gray">接收人<font>*</font></td>
			<td>
				<input type="text" name="to_unames" value="{$detail.to_unames|default=''}" lay-verify="required" lay-reqText="请选择接收人" placeholder="请选择接收人" readonly class="layui-input picker-admin" data-type="2">
				<input type="hidden" name="to_uids" value="{$detail.to_uids|default=''}">
			</td>
			{else/}
			<td class="layui-td-gray">接收人</td>
			<td>{$detail.to_unames|default=''}</td>
			{/if}
			<td class="layui-td-gray">汇报周期<font>*</font></td>
			<td><input type="text" class="layui-input tool-time" data-range="~" name="range_date" readonly value="{$detail.range_date|default=''}" lay-verify="required" lay-reqText="请完善汇报周期"></td>
		</tr>		
		<tr>
			<td class="layui-td-gray">本周工作<font>*</font></td>
			<td colspan="3"><textarea name="works" placeholder="请输入本周工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入本周工作内容">{$detail.works|default=''}</textarea></td>
		</tr>
		<tr><td class="layui-td-gray">下周计划</td>
			<td colspan="3"><textarea name="plans" placeholder="请输入下周计划" class="layui-textarea" style="height: 120px;">{$detail.plans|default=''}</textarea></td>
		</tr>
		<tr><td class="layui-td-gray">其它事项</td>
			<td colspan="3"><textarea name="remark" placeholder="请输入其它事项" class="layui-textarea" style="height: 120px;">{$detail.remark|default=''}</textarea></td>
		</tr>
		<tr>
			<td class="layui-td-gray"><div class="layui-input-inline">附件</div> <div class="layui-input-inline"><button type="button" class="layui-btn layui-btn-xs" id="uploadBtn"><i class="layui-icon"></i></button></div></td>
			<td colspan="3">
				<div class="layui-row" id="uploadBox">
					<input type="hidden" name="file_ids" data-type="file" value="{$detail.file_ids|default=''}">
					{notempty name="$detail.file_array"}
					{volist name="$detail.file_array" id="vo"}
					<div class="layui-col-md4">{:file_card($vo)}</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>
	</table>
	<div class="pt-4">
		<input type="hidden" value="{$id}" name="id">
		<input type="hidden" value="{$types}" name="types">
		<input type="hidden" value="0" name="send">
		<button class="layui-btn" lay-submit="" lay-filter="webform1">仅保存</button>
		{if ($id == 0) OR ($detail.send_time == 0) }
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">保存并发送</button>
		{/if}
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool','oaPicker','uploadPlus'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,uploadPlus = layui.uploadPlus;
		var attachment = new uploadPlus({
			"title":'上传文件',
			"target":'uploadBtn',
			"targetBox":'uploadBox'
		});
		//监听发送
		form.on('submit(webform)', function(data){
			if(data.field.uids==login_admin){
				layer.msg('接收人不能是自己');
				return false;
			}
			data.field.send=1;
			tool.ask('确定要保存后直接发送该工作汇报吗?', function(index){
				$.ajax({
					url: "/oa/work/add",
					type:'post',
					data:data.field,
					success:function(e){
						layer.msg(e.msg);
						if (e.code == 0) {						
							tool.sideClose(1000);
						}
					}
				})
				layer.close(index);
			});
			return false;
		});
		
		//监听保存
		form.on('submit(webform1)', function(data){
			tool.ask('确定要仅保存该工作汇报吗?', function(index){
				$.ajax({
					url: "/oa/work/add",
					type:'post',
					data:data.field,
					success:function(e){
						layer.msg(e.msg);
						if (e.code == 0) {						
							tool.sideClose(1000);
						}
					}
				})
				layer.close(index);
			});
			return false;
		});
	}		
	</script>
{/block}
<!-- /脚本 -->